//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_MATERIAL_INTERFACE_H
#define _UX_MATERIAL_INTERFACE_H

#include "../CResource.h"

namespace Engine
{
namespace Resources
{


	//
	// Material Texture
	//

	struct TMaterialTexture
	{
		CTexturePtr		pTexture;
		e_texture::type	eType;
		uint8			uStage;
		///
		TMaterialTexture():
			pTexture(nullptr), uStage(0), eType(e_texture::UNKNOWN) {}

		TMaterialTexture(const CTexturePtr &tex, e_texture::type type, uint8 stage):
			pTexture(tex), eType(type), uStage(stage) {}
	};




	//
	// Material Layer interface
	//

	class IMaterialLayer
	{
	public:
		virtual void  Free() = 0;
		virtual void  Apply() = 0;
		virtual uint  GetMaterialLOD() const = 0;
		virtual bool  Link(const IProgramPtr &pProgram, uni_array<uint32> aStages) = 0;
		virtual bool  GetLinkProgram(const uni_array<const GLVertexAttribInfo> &aMeshAttribs,
									 IProgramPtr &pProg, uni_array<uint32> aStages) = 0;
		virtual e_render_layer::type GetRenderLayer() const = 0;
	};



	//
	// Material interface
	//

	class _EXPORT_ IMaterial : public CResource
	{
	public:
		typedef array< IMaterialLayer *, TFastCopyStrategy< IMaterialLayer *> >		mtrlayer_array_t;
		typedef uni_array< IMaterialLayer *>										mtrlayer_uni_array_t;

	public:
		virtual bool IsExist(e_render_layer::type eLayer, uint uLOD) = 0;
		virtual bool GetLayer(IMaterialLayer *&pLayer, e_render_layer::type eLayer, uint uLOD) = 0;
		virtual void GetUniqueLayers(mtrlayer_uni_array_t &aLayers) = 0;
		virtual e_render_layer::bits GetLayerBits() const = 0;
	};
	
//-------------------------------------------------------------------

}	// Resources
}	// Engine

#endif	// _UX_MATERIAL_INTERFACE_H